<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<div id="main">
    window对象

    <button onclick="myFunction()">点击我</button>
    <button onclick="myFunction1()">试一试</button>
    <p id="demo" class="p1 p2 p3 p4"></p>
    <button onclick="myFunction2()">试一试</button>
    <p id="demo1">text</p>
</div>

<body>

</body>
<script>
    // console.log(window.innerHeight)
    // console.log(window.innerWidth)
    function myFunction() {
        alert("I am a warning box！");
    }

    function myFunction1() {
        var txt;
        if (confirm("press a button")) {
            txt = "You press ok";
        } else {
            txt = "You pressed cancel";
        }

        document.getElementById("demo").innerHTML = txt;
    }

    function myFunction2() {
        let txt1;
        let person = prompt("Please enter your name：", "Please entar your name");
        if (person == null || person == "") {
            txt1 = "User cancels input";
        } else {
            txt1 = "Hello，" + person + "!How are you doing today？";
        }
        document.getElementById("demo1").innerHTML = txt1;
    }

    var a = screen.width;
    console.log(a)
    var b = location.href;
    var c = location.hostname;
    var d = location.pathname;
    var e = location.protocol;
    console.log(b, c, d, e)
    console.log(location)
        // var f = navigator.product;
        // var g = navigator.appVersion;
        // console.log(f, g)
    console.log(navigator)
    console.dir(document)

    const p = document.getElementById("demo");
    //返回标签上的所有属性
    for (let i of p.attributes) {
        console.log(i)
    }
    //返回该元素包含的class属性
    for (let i of p.classList) {
        console.log(i)
    }

    const div = document.getElementById("main");
    //表示这个元素的内容文本
    console.log(div.innerHTML)
        //返回元素的高度
    console.log(div.offsetHeight)
        // div.appendChild("<p>向元素添加新的子节点，作为最后一个子节点</p>")
    console.log(div.firstChild)
        //清空控制台
        // console.clear()
        //返回浏览器历史列表中的URL数量
    let he = window.history.length;
    console.log(he)
</script>

</html>